﻿using A.M.ETO;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using Public_Class_Library;
using Q.M.Finance.Domain.Entity;
using System.Drawing.Printing;
using System.Linq.Expressions;
using W.M.Materiel.Application.IServices;
using W.M.Materiel.Domain.Entity;
using W.M.Materiel.Infrastruecure.IRepository;

namespace W.M.Materiel.Read.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class Purchase_order_tableController : ControllerBase
    {
        private readonly IPurchase_order_tableServices purchase_Order_TableServices;

        public Purchase_order_tableController(IPurchase_order_tableServices purchase_Order_TableServices)
        {
            this.purchase_Order_TableServices = purchase_Order_TableServices;
        }

        /// <summary>
        /// 采购信息+分页+查询
        /// </summary>
        /// <param name="pageSize">页容量</param>
        /// <param name="pageIndex">当前页</param>
        /// <param name="id">查询条件：采购单价</param>
        /// <returns>统一返回格式</returns>
        [HttpGet]
        public async Task<IActionResult> GetPurchase_Order_Table(int pageSize, int pageIndex, string? id)
        {
            var list=await purchase_Order_TableServices.GetPurchase_Order_Table(pageSize, pageIndex, id);
            return Ok(list);
        }
        /// <summary>
        /// 根据采购单号反填收款方信息
        /// </summary>
        /// <param name="salesid"></param>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetInfo(string purchase_code)
        {
            var list =purchase_Order_TableServices.GetInfo(purchase_code);
            return Ok(list);
        }
        /// <summary>
        /// 反填采购订单
        /// </summary>
        /// <param name="salesid"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> FindsalesInfo(string? purchase_code)
        {
            var list =await purchase_Order_TableServices.FindsalesInfo(purchase_code);
            return Ok(list);

        }
    }
}
